<?php
// +----------------------------------------------------------------------
// | Tplay [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://tplay.pengyichen.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 听雨 < 389625819@qq.com >
// +----------------------------------------------------------------------


namespace app\admin\controller;

use app\admin\controller\Permissions;
use \think\Db;
class Webconfig extends Permissions
{

    public function add()
    {
        
    	if($this->request->isPost()) {
            $post = $this->request->post();
            // var_dump($post);exit;
            if(false == Db::name('webconfig')->where('class',$post['class'])->update($post)) {
                return $this->error('提交失败');
            } else {
                // addlog();
                return $this->success('提交成功','admin/webconfig/index?class='.$post['class']);
            }
        }else{
            $webconfig=Db::name('webconfig')->where('class',$this->request->param('class'))->find();
            
            switch ($this->request->param('class')) {
            case 'web':
                $webconfig['index']='网站须知';
                break;
            case 'falv':
                $webconfig['index']='法律条款';
                break;
            case 'yinsi':
                $webconfig['index']='隐私条款';
                break;
                case 'reg':
                $webconfig['index']='注册协议';
                break;
        }

            $this->assign("webconfig",$webconfig);
            return $this->fetch();
        }
    }

    public function index(){
        $webconfig=Db::name('webconfig')->where('class',$this->request->param('class'))->find();
        switch ($this->request->param('class')) {
            case 'web':
                $webconfig['index']='网站须知';
                break;
            case 'falv':
                $webconfig['index']='法律条款';
                break;
            case 'yinsi':
                $webconfig['index']='隐私条款';
                break;
            case 'reg':
                $webconfig['index']='注册协议';
                break;
        }
            $this->assign("webconfig",$webconfig);
            return $this->fetch();
    }



}
